home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / intcase.com / INTCASE.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-07-27  |  1.6 KB  |  77 lines

  1. dseg    segment    word
  2.     assume ds:dseg
  3.  
  4.     extrn DosUpcase                 : dword
  5.         extrn LocaseTranslationtable : byte
  6.  
  7. dseg    ends
  8.  
  9. cseg    segment    word
  10.     assume cs:cseg
  11.  
  12.     locals @@
  13.  
  14. dummy   proc    far
  15. ; DosUpcase points to here under DOS < 3.0
  16.         public  dummy
  17.  
  18.         retf
  19. dummy   endp
  20.  
  21. ; function upcase ----------------------------
  22. upcase    proc    far
  23.     public    upcase
  24.         mov     bx,sp
  25.         mov     al,ss:[bx+4]   ; Get character into al
  26.  
  27.         cmp    al,97           ; 'a'
  28.     jb    @@1            ; If below, it can't be converted
  29.  
  30.     cmp    al,122           ; 'z'
  31.     jbe     @@2            ; If below, it's a standard lower case char
  32.  
  33.     call    [DosUpcase]    ; Let DOS do the conversion
  34.                                ; DOS ignores characters below #128
  35.  
  36.     jmp    short @@1
  37.  
  38. @@2:    sub    al,32          ; Convert to upper case
  39.  
  40. @@1:    retf    2              ; Remove parameter and return
  41.  
  42. upcase    endp
  43.  
  44. ; function locase ----------------------------
  45.  
  46. locase    proc    far
  47.     public    locase
  48.  
  49.         mov     bx,sp
  50.         mov     al,ss:[bx+4]   ; Get character into al
  51.  
  52.         cmp    al,65           ; 'A'
  53.     jb    @@1            ; If below, it can't be converted
  54.  
  55.     cmp    al,90           ; 'Z'
  56.     jbe    @@2            ; If below, it's a standard upper case char
  57.  
  58.         cmp     al,127         ; Is it in the extended char range ?
  59.     jbe    @@1            ; No, cannot convert
  60.  
  61.     sub    al,128         ; Yes, relocate for table [128..255]
  62.  
  63.     mov    bx,offset LocaseTranslationtable
  64.     xlat                   ; Actual convertion
  65.  
  66.     jmp    short @@1
  67.  
  68. @@2:    add    al,32          ; Convert to lower case
  69.  
  70. @@1:    retf    2              ; Remove parameter and return
  71.  
  72. locase    endp
  73.  
  74. cseg    ends
  75.  
  76.     end
  77.